﻿@model Zor_Web.Models.Base.V_Disannul
@using Webdiyer.WebControls.Mvc;
@using Zor_Tools;
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>消号管理</title>
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Styles/zor.css" rel="stylesheet" />
    <!-- 框架必要 -->
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/Zor_AJax.js"></script>
    <!-- 消息提示 -->
    <script src="~/Content/layer/layer.js"></script>
    <!-- 日期选择器 -->
    <script src="~/Content/laydate/laydate.js"></script>

    <!-- 表单验证 -->
    <script src="~/Content/Scripts/JValidator.js"></script>

</head>
<body class="gray-bg">
    <div class="layui-tab layui-tab-brief main-tab-container ">
        <div class="col-sm-12 ct-padding">
            <div class="col-sm-9 ct-padding">
                <button id="btnSure" class="layui-btn layui-btn-crimson layui-btn-small"><span class="glyphicon glyphicon-remove"></span> 消号</button>
                <button id="btnSearch" class="layui-btn layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-search"></span> 查询</button>
                <button id="btnMessage" class="layui-btn layui-btn-orchid  layui-btn-small"><span class="glyphicon glyphicon-list-alt"></span> 详情</button>
                <button id="btnReplace" class="layui-btn layui-btn-blue layui-btn-small"><span class="glyphicon glyphicon-refresh"></span> 刷新</button>
            </div>
        </div>
        <div class="layui-tab-content">
          
            <table class="layui-table" lay-skin="line">
                <thead>
                    <tr>
                        <th hidden></th>
                        <th></th>
                        <th>汇总单号</th>
                        <th>操作员名称</th>
                        <th>汇总金额(元)</th>
                        <th>汇总时间</th>
                        <th>消号状态</th>  
                    </tr>
                </thead>
                <tbody id="accordion">
                    @foreach (var item in Model.PageData)
                    {
                        <tr>
                            <td hidden>@item.Dn_Id</td>
                            <td><input type="radio" name="chk" id="@item.Dn_Id" value="@item.Dn_Id" /></td>
                            <td>@item.Dn_Number</td>
                            <td>@item.DnUser</td>
                            <td>@(item.Dn_ActtualTax*0.01)</td>
                            <td>@TimeHelper.TimeStampToDateTime(item.Dn_Date.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                            <td>@item.DnState</td>
                            <td hidden>@item.Acceptance_Id</td>   
                            <td hidden>@item.Dn_Date</td>    
                            <td hidden>@item.Bd_Id</td> 
                            <td hidden>@(item.Grsds*0.01)</td>  
                            <td hidden>@(item.Fcs*0.01)</td>     
                        </tr>
                    }
                </tbody>
            </table>
            <input id="Dn_Id" type="hidden">
            <input id="accpid" type="hidden">
            <input id="actualtax" type="hidden">
            <input id="dndate" type="hidden">
        </div>
        <div class="col-sm-12">
            <div class="col-sm-10">
                @Html.Pager(Model.PageData, new PagerOptions { PageIndexParameterName = "index", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>", PagerItemWrapperFormatString = "<li>{0}</li>" }, new { id = "bootstrappager", @class = "pagination" })
            </div>
            <div class="col-sm-2 to-righjt">
                共 @Model.PageData.TotalItemCount 条记录，页 @Model.PageData.CurrentPageIndex/@Model.PageData.TotalPageCount
            </div>
        </div>
    </div>

    @using (Html.BeginForm("Disannul", "Base", new RouteValueDictionary { { "Model", Model } }, FormMethod.Get))
    {
    <!-- 查询模态框 -->
        <div id="myModalSearch" hidden data-backdrop="static">
            <div id="divfrom" class="layui-tab-content">
                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">消号时间：</label>
                    <div class="col-sm-9">
                        <input id="Sm_Date" name="Sm_Date" type="text" class="laydate-icon  form-control layer-date" onclick="laydate({ istime: false, format: 'YYYY-MM-DD' })" value="@Model.Dn_Date">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">消号状态：</label>
                    <div class="col-sm-9">
                        <select name="DnState" class="form-control">
                            <option value="全部">全部</option>
                            <option value="@Model.DnState">待消号</option>
                            <option value="@Model.DnState">已消号</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">汇总人：</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" name="DnUser" value="@Model.DnUser">
                    </div>
                </div>
                <button type="submit" class="btn btn-info pull-right">查询</button> 
            </div>
        </div>
    }

    <div id="myModalXiaoHao" hidden data-backdrop="static">
     
        <div class="layui-tab-content">
          
                <div class="layui-form-item">
                    <label class="col-sm-3 layui-form-label">缴款书编号：</label>
                    <div class="col-sm-5">
                        <input id="Dn_Jksbh" type="text" class="form-control" placeholder="请输入缴款书编号" autofocus="autofocus" datacol="yes" err="缴款书编号" checkexpession="NotNull">
                    </div>
                    <div class="col-sm-4">
                        <button id="btnSuresub" class="layui-btn layui-btn-danger layui-btn-small"><span class="glyphicon glyphicon-plus"></span> 保存</button>
                    </div>
                </div>
              
             
                <table class="layui-table" lay-skin="line">
                    <thead>
                        <tr>
                            <th hidden></th>
                            <th>社区</th>
                            <th>受理单号</th>
                            <th>税金(元)</th>
                            <th>起征日期</th>
                            <th>征止日期</th>
                            <th>缴税日期</th>
                            <th>经办人</th>
                            <th>房屋属性</th>
                            <th>纳税人</th>
                            <th>联系方式</th>
                            <th>面积</th>
                        </tr>
                    </thead>
                    <tbody id="accordions"></tbody>
                </table>
</div>
    </div>

    <div id="myModalMessage" hidden data-backdrop="static">
        <div class="layui-tab-content">
            <table class="layui-table" lay-skin="line">
                <thead>
                    <tr>
                        <th hidden></th>
                        <th>社区</th>
                        <th>受理单号</th>
                        <th>税金(元)</th>
                        <th>起征日期</th>
                        <th>征止日期</th>
                        <th>缴税日期</th>
                        <th>经办人</th>
                        <th>房屋属性</th>
                        <th>纳税人</th>
                        <th>联系方式</th>
                        <th>面积</th>
                    </tr>
                </thead>
                <tbody id="accordiond"></tbody>
            </table>
        </div>
    </div>
</body>
</html>
<script>

    laydate(
    { elem: "#Sm_Date", event: "focus" });

    laydate.skin('molv');         //日历皮肤

    /** 刷新**/

    $(function () {
        $("#btnReplace").click(function () {
            Replace();
        })
    })
    /*** 全选*/
    $(function () {
        $("#cbkCheckAll").click(function () {
            if (this.checked) {
                $("input[name='chk']").prop('checked', true);
            } else {
                $("input[name='chk']").prop('checked', false);
            }
        })
    })

    $(function () {
    /*** 消号详情*/
    $("#btnMessage").click(function () {
        var checkId = CheckboxValueIDs();//消号主id  
        if (checkId.length == 0) {
            layer.msg("请选择要消号的信息！");                                                             //未选中任何行
            return;
        }
        if (checkId.length > 1) {
            layer.msg("只能选择一条信息");                                                             //未选中任何行
            return;
        }     
        LayerOpen('1150px', '580px', '详情列表', $('#myModalMessage'));
        var html = "";
        getAjax("/Base/Disannul_Operation", { where: checkId[0] }, function (data) {
            accordionJson = eval("(" + data + ")");
            $.each(accordionJson, function (i) {              
                html += "<tr>";
                html += "<td hidden>" + accordionJson[i].Sm_Id + "</td>";
                html += "<td>" + accordionJson[i].CommunityName + "</td>";
                html += "<td>" + accordionJson[i].Acceptance_TicketNumber + "</td>";
                html += "<td>" + (accordionJson[i].ETax)*0.01 + "</td>";
                html += "<td>" + TimeStampToDateTime(accordionJson[i].Acceptance_TaxStartTime, 'yyyy-MM-dd ') + "</td>";
                html += "<td>" + TimeStampToDateTime(accordionJson[i].Acceptance_TaxEndTime, 'yyyy-MM-dd ') + "</td>";
                html += "<td>" + TimeStampToDateTime(accordionJson[i].Pt_Date, 'yyyy-MM-dd ') + "</td>";
                html += "<td>" + accordionJson[i].InUser + "</td>";
                html += "<td>" + accordionJson[i].AHA + "</td>";
                html += "<td>" + accordionJson[i].NatPer_Name + "</td>";
                html += "<td>" + accordionJson[i].NatPer_Phone + "</td>";
                html += "<td>" + accordionJson[i].Hs_Proportion + "</td>";
                html += "</tr>";
            });
        })
        $("#accordiond").empty().append(html);
      
    })
    
    /*查询*/
    $("#btnSearch").click(function () {
        LayerOpen('500px', '250px', '查询', $('#myModalSearch'));
    });

    /*** 消号显示列表*/    
    $("#btnSure").click(function () {
        var checkId = CheckboxValueIDs();//消号主id    
            DnState = getTableCell(6);
            if (checkId.length == 0) {
                layer.msg("请选择要消号的信息！");                                                             //未选中任何行
                return;
            }
            if (checkId.length > 1) {
                layer.msg("只能选择一条信息");                                                             //未选中任何行
                return;
            }
            if (DnState == "已消号") {
                layer.msg("已消号无需重复操作");                                                             //未选中任何行
                return;
            }
                 
            var accpid = getTableCell(7);//受理单号
            var actualtax = getTableCell(4);//汇总总额
            var dndate = getTableCell(8);//消号时间
         
            LayerOpen('1150px', '500px', '待消号列表信息', $('#myModalXiaoHao'));
            var html = "";           
            getAjax("/Base/Disannul_Operation", { where: checkId[0] }, function (data) {
                accordionJson = eval("(" + data + ")");             
                $.each(accordionJson, function (i) {
                    html += "<tr>";
                    html += "<td hidden>" + accordionJson[i].Sm_Id + "</td>";
                    html += "<td hidden>" + accordionJson[i].CommunityId + "</td>";
                    html += "<td>" + accordionJson[i].CommunityName + "</td>";
                    html += "<td>" + accordionJson[i].Acceptance_TicketNumber + "</td>";
                    html += "<td>" + (accordionJson[i].ETax)*0.01 + "</td>";
                    html += "<td>" + TimeStampToDateTime(accordionJson[i].Acceptance_TaxStartTime, 'yyyy-MM-dd ') + "</td>";
                    html += "<td>" + TimeStampToDateTime(accordionJson[i].Acceptance_TaxEndTime, 'yyyy-MM-dd ') + "</td>";
                    html += "<td>" + TimeStampToDateTime(accordionJson[i].Pt_Date, 'yyyy-MM-dd') + "</td>";
                    html += "<td>" + accordionJson[i].InUser + "</td>";
                    html += "<td>" + accordionJson[i].AHA + "</td>";
                    html += "<td>" + accordionJson[i].NatPer_Name + "</td>";
                    html += "<td>" + accordionJson[i].NatPer_Phone + "</td>";
                    html += "<td>" + accordionJson[i].Hs_Proportion + "</td>";
                    html += "</tr>";
                });
            })
            $("#accordions").empty().append(html);
    })
    /*** 消号保存*/
    $("#btnSuresub").click(function () {           
        if (!CheckDataValid('.layui-form-item')) {
            return false;
        }
            var checkId = CheckboxValueIDs();//消号主id  
            var accpid = getTableCell(7);//受理单号
            var actualtax = getTableCell(4);//汇总总额
            var dndate = getTableCell(8);//消号时间   
            var Bdid = getTableCell(9);//楼宇id 
            var Grsds = getTableCell(10);//个人所得税
            var Fcs = getTableCell(11);//房产税
            var Jksbh = $("#Dn_Jksbh").val();//缴款书编号
           // alert(checkId[0] + "|" + accpid + "|" + actualtax + "|" + Fcs + "|" + Grsds);
            ZorPostSimpleData("/Base/SummaryDisannul", JSON.stringify({ "Dn_Id": checkId[0], "accpid": accpid, "Grsds": Grsds, "Fcs": Fcs, "actualtax": actualtax, "dndate": dndate, "Jksbh": Jksbh, "Bd_Id": Bdid }), function (data) {
                layer.msg(data.AnswerMeg, function () {
                    layer.closeAll();
                    Replace();
                });
            });
        })
    })
</script>